home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Mac / Modules / list / listscan.py < prev    next >
Text File  |  1996-04-12  |  2KB  |  75 lines

  1. # Scan an Apple header file, generating a Python file of generator calls.
  2.  
  3. import addpack
  4. addpack.addpack(':tools:bgen:bgen')
  5. from scantools import Scanner
  6. from bgenlocations import TOOLBOXDIR
  7.  
  8. LONG = "Lists"
  9. SHORT = "list"
  10. OBJECT = "ListRef"
  11.  
  12. def main():
  13.     input = LONG + ".h"
  14.     output = SHORT + "gen.py"
  15.     defsoutput = TOOLBOXDIR + LONG + ".py"
  16.     scanner = MyScanner(input, output, defsoutput)
  17.     scanner.scan()
  18.     scanner.close()
  19.     print "=== Done scanning and generating, now importing the generated code... ==="
  20.     exec "import " + SHORT + "support"
  21.     print "=== Done.  It's up to you to compile it now! ==="
  22.  
  23. class MyScanner(Scanner):
  24.  
  25.     def destination(self, type, name, arglist):
  26.         classname = "Function"
  27.         listname = "functions"
  28.         if arglist:
  29.             t, n, m = arglist[-1]
  30.             # This is non-functional today
  31.             if t == OBJECT and m == "InMode":
  32.                 classname = "Method"
  33.                 listname = "methods"
  34.         return classname, listname
  35.  
  36.     def makeblacklistnames(self):
  37.         return [
  38.             "LDispose",        # Done by removing the object
  39.             "LSearch",        # We don't want to handle procs just yet
  40.             "LGetCellDataLocation",        # What does this do??
  41.             ]
  42.  
  43.     def makeblacklisttypes(self):
  44.         return [
  45.             ]
  46.  
  47.     def makerepairinstructions(self):
  48.         return [
  49.             ([('ListBounds_ptr', '*', 'InMode')],
  50.              [('Rect_ptr', '*', 'InMode')]),
  51.  
  52.             ([("Cell", "theCell", "OutMode")],
  53.              [("Cell", "theCell", "InOutMode")]),
  54.              
  55.             ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
  56.              [("InBufferShortsize", "*", "*")]),
  57.             
  58.             ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
  59.              [("VarOutBufferShortsize", "*", "InOutMode")]),
  60.             
  61. #            ([("void", "wStorage", "OutMode")],
  62. #             [("NullStorage", "*", "InMode")]),
  63. #            
  64. #            # GetKeys
  65. #            ([('KeyMap', 'theKeys', 'InMode')],
  66. #             [('*', '*', 'OutMode')]),
  67. #             
  68. #            # GetTicker
  69. #            ([('unsigned long', '*', '*')],
  70. #             [('unsigned_long', '*', '*')]),
  71.             ]
  72.             
  73. if __name__ == "__main__":
  74.     main()
  75.